import { defineConfig } from 'vitepress'
import renderPermaLink from './render-perma-link'
import MarkDownItCustomAnchor from './markdown-it-custom-anchor'
import mdItCustomAttrs  from 'markdown-it-custom-attrs'

const ogDescription = 'ThingsKit是一套开箱即用的物联网低代码平台，提供N+1+N（N个终端产品+1个物联网平台+N套行业方案）的产品服务体系，帮助企业快速搭建稳定可靠的物联网系统平台，为企业节省大量时间及人力成本。'
const ogImage = '/logo.png'
const ogTitle = 'ThingsKit'
const ogUrl = 'https://www.thingskit.com'

export default defineConfig({
  title: 'ThingsKit',
  description: 'ThingsKit是一套开箱即用的物联网低代码平台，提供N+1+N（N个终端产品+1个物联网平台+N套行业方案）的产品服务体系，帮助企业快速搭建稳定可靠的物联网系统平台，为企业节省大量时间及人力成本。',
  lang: 'zh-CN',
  lastUpdated: true,
  ignoreDeadLinks: true,

  head: [
    ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.png' }],
    ["link", { rel: "stylesheet", href: "https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" }],
    ["script", { src: "https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.umd.js" }],
    ['meta', { property: 'og:type', content: 'website' }],
    ['meta', { property: 'og:title', content: ogTitle }],
    ['meta', { property: 'og:image', content: ogImage }],
    ['meta', { property: 'og:url', content: ogUrl }],
    ['meta', { property: 'og:description', content: ogDescription }],
    ['meta', { name: 'twitter:card', content: 'summary_large_image' }],
    ['meta', { name: 'twitter:site', content: 'GoView' }],
    ['meta', { name: 'theme-color', content: '#3f8bdb' }],
    [
      'script',
      {
        src: '',
        'data-site': '',
        'data-spa': '',
        defer: ''
      }
    ]
  ],

  vue: {
    reactivityTransform: true
  },

  themeConfig: {
    logo: '/logo.png',
    outlineTitle: '本页目录',
    editLink: {
      text: '为此页提供修改建议',
      pattern: 'https://gitee.com/thingskit/thingskit-docs/blob/master/:path'
    },

    footer: {
      copyright: '@ 2023 云腾五洲 蜀ICP备2020033344号'
    },

    nav: [
      { text: '指南', link: '/guide/start/', activeMatch: '/guide/start/index' },
      // { text: '教程', link: '/tutorial/', activeMatch: '/tutorial/index' },
      { text: 'API', link: '/api/home/index', activeMatch: '/api/home/index' },
      { text: '商业授权', link: 'https://www.thingskit.com/pricing', activeMatch: 'https://www.thingskit.com/pricing' },
      /*{
        text: '相关链接',
        items: [
          {
            text: 'Vue3',
            link: 'https://cn.vuejs.org/'
          },
          {
            text: 'Vben Admin',
            link: 'https://github.com/vbenjs/vue-vben-admin'
          },
          {
            text: 'Vite',
            link: 'https://cn.vitejs.dev/'
          },
          {
            text: 'TypeScript',
            link: 'https://www.typescriptlang.org/'
          },
          {
            text: 'ECharts',
            link: 'https://echarts.apache.org/zh/index.html'
          },
          {
            text: 'ThingsBoard',
            link: 'https://thingsboard.io/'
          },
        ]
      },*/
      { text: 'ThingsKit官网', link: 'https://www.thingskit.com/'}
    ],

    sidebar: {
      '/guide/': [
        {
          text: '平台介绍',
		  collapsible: true,
          items: [
            {
              text: '什么是ThingsKit？',
              link: '/guide/start/index'
            },
            {
              text: '如何连接您的设备？',
              link: '/guide/start/connectivity'
            },
            {
              text: '技术栈',
              link: '/guide/start/tech-stack'
            },
            {
              text: '更新日志',
              link: '/guide/start/update-log'
            },
            {
              text: '路线图',
              link: '/guide/start/roadmap'
            },
          ]
        },
        {
          text: '快速上手',
          collapsible: true,
          collapsed: true,
          items: [
            {
              text: '准备工作',
              link: '/guide/quick-start/ready'
            },
            {
              text: '设备数据上报',
              link: '/guide/quick-start/report'
            },
            {
              text: '设备命令下发',
              link: '/guide/quick-start/push'
            },
            {
              text: '使用数据看板',
              link: '/guide/quick-start/data-view'
            },
            {
              text: '配置设备告警',
              link: '/guide/quick-start/alarm'
            },
          ]
        },
        {
          text: '设备接入',
          collapsible: true,
          collapsed: true,
          items: [
            // {
            //   text: '设备的接入方式和协议',
            //   link: '/guide/device-connect/'
            // },
            // {
            //   text: '设备证书',
            //   link: '/guide/device-connect/report'
            // },
            {
              text: '直连设备MQTT接入',
              link: '/guide/device-connect/mqtt'
            },
            {
              text: '网关设备MQTT接入',
              link: '/guide/device-connect/gateway-mqtt'
            },
            {
              text: '设备TCP接入',
              link: '/guide/device-connect/tcp'
            },
            {
              text: '设备CoAP接入',
              link: '/guide/device-connect/coap'
            },
            {
              text: '设备HTTP接入',
              link: '/guide/device-connect/http'
            },
            // {
            //   text: '通信模组AT接入',
            //   link: '/guide/device-connect/module-at'
            // },
            // {
            //   text: '透传模组接入',
            //   link: '/guide/device-connect/module-transparent'
            // },
          ]
        },
        // {
        //   text: '数据可视化',
        //   collapsible: true,
        //   collapsed: true,
        //   items: [
        //     {
        //       text: '数据看板',
        //       link: '/guide/visualization/dashboard'
        //     },
        //     {
        //       text: 'Web组态',
        //       link: '/guide/visualization/scada'
        //     },
        //     {
        //       text: '数据大屏',
        //       link: '/guide/visualization/data-view'
        //     },
        //   ]
        // },
        {
          text: '基础操作手册',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '设备管理',
              link: '/guide/operation/device'
            },
            {
              text: '规则引擎',
              link: '/guide/operation/rule-engine'
            },
            {
              text: '可视化管理',
              link: '/guide/operation/visual'
            },
            {
              text: '告警管理',
              link: '/guide/operation/alarm'
            },
            {
              text: '视频管理',
              link: '/guide/operation/video'
            },
            {
              text: '报表管理',
              link: '/guide/operation/report'
            },
            {
              text: '定时任务',
              link: '/guide/operation/task'
            },
            {
              text: '运维管理',
              link: '/guide/operation/maintenance'
            },
            {
              text: '消息管理',
              link: '/guide/operation/message'
            },
            {
              text: '平台通知',
              link: '/guide/operation/platform-notice'
            },
            {
              text: '系统管理',
              link: '/guide/operation/tenant-sys'
            },
            {
              text: '租户管理(超级权限)',
              link: '/guide/operation/tenant'
            },
            {
              text: '系统管理(超级权限)',
              link: '/guide/operation/platform-sys'
            },
            {
              text: '小程序APP',
              link: '/guide/operation/app'
            },
          ]
        },
        {
          text: '安装部署',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: 'Docker部署',
              link: '/guide/install/docker'
            },
            {
              text: 'Jar包部署',
              link: '/guide/install/jar.md'
            },
			{
              text: '版本升级指南',
              link: '/guide/install/update.md'
            },
            {
              text: '配置文件说明',
              link: '/guide/install/configuration.md'
            },
          ]
        },
        {
          text: '常见问题',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '常见问题',
              link: '/guide/faq/index'
            }
          ]
        },
      ],
    '/develop/': [
      {
        text: '二开基础教程',
        collapsible: true,
        collapsed: false,
        items: [
          {
            text: '源代码目录结构说明',
            link: '/develop/base/directory-desc'
          },
          {
            text: '数据库表及字段说明',
            link: '/develop/base/db-desc'
          },
          {
            text: '本地运行ThingsKit',
            link: '/develop/base/thingskit-server'
          },
          {
            text: '后端打包部署',
            link: '/develop/base/publish-thingskit'
          },
          {
            text: '平台角色权限说明',
            link: '/develop/base/role-desc'
          },
          {
            text: '设备与平台交互流程说明',
            link: '/develop/base/device-thingskit-desc'
          },
          {
            text: '平台PC端界面开发指南',
            link: '/develop/base/thingskit-ui'
          },
          {
            text: '平台组态软件开发指南',
            link: '/develop/base/thingskit-scada'
          },
          {
            text: '平台小程序APP开发指南',
            link: '/develop/base/thingskit-app'
          }
        ]
      },
      {
        text: '二开进阶教程',
        collapsible: true,
        collapsed: true,
        items: [
          {
            text: '说明',
            link: '/develop/advanced/'
          },
        ]
      },
      {
        text: '常见问题',
        collapsible: true,
        collapsed: true,
        items: [
          {
            text: '二开常见问题',
            link: '/develop/faq'
          },
        ]
      },
    ],
    '/api/': [
        {
          text: '首页',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '概览汇总',
              link: '/api/home/index'
            }
		]
		},
		{
          text: '设备管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '产品',
              link: '/api/device/product/'
            },
            {
              text: '设备',
              link: '/api/device/device/'
            },
            {
              text: '地理位置',
              link: '/api/device/localtion/'
            }
		]
		},
		{
          text: '规则引擎',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '场景联动',
              link: '/api/rule/linkedge/'
            },
            {
              text: '数据流转',
              link: '/api/rule/data-flow/'
            },
            {
              text: 'MQTT脚本转换',
              link: '/api/rule/mqtt-script/'
            },
            {
              text: 'TCP脚本转换',
              link: '/api/rule/tcp-script/'
            }
		]
		},
		{
          text: '可视化管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '数据看板',
              link: '/api/visual/board/'
            },
            {
              text: '组态中心',
              link: '/api/visual/scada/'
            }
		]
		},
		{
          text: '告警管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '告警记录',
              link: '/api/alarm/log/'
            },
            {
              text: '告警联系人',
              link: '/api/alarm/contacts/'
            },
            {
              text: '告警配置',
              link: '/api/alarm/config/'
            }
		]
		},
		{
          text: '视频管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '视频配置',
              link: '/api/camera/manage/'
            },
            {
              text: '流媒体配置',
              link: '/api/camera/streaming/'
            }
		]
		},
		{
          text: '报表管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '报表配置',
              link: '/api/report/config/'
            },
            {
              text: '报表导出',
              link: '/api/report/export/'
            }
		]
		},
		{
          text: '运维管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '设备上下线',
              link: '/api/maintenance/onlinerecord/'
            },
            {
              text: 'OTA升级',
              link: '/api/maintenance/ota/'
            }
		]
		},
		{
          text: '消息管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '消息记录',
              link: '/api/message/log/'
            },
            {
              text: '消息配置',
              link: '/api/message/config/'
            },
            {
              text: '消息模板',
              link: '/api/message/template/'
            }
		]
		},
		{
          text: '平台通知',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '我的通知',
              link: '/api/notice/my-notices/'
            },
            {
              text: '通知管理',
              link: '/api/notice/manager/'
            }
		]
		},
		{
          text: '租户管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '租户',
              link: '/api/tenant/account/'
            },
            {
              text: '租户配置',
              link: '/api/tenant/config/'
            },
            {
              text: '租户角色',
              link: '/api/tenant/role/'
            }
		]
		},
		{
          text: '系统管理',
		  collapsible: true,
		  collapsed: true,
          items: [
            {
              text: '平台定制',
              link: '/api/system/customize/'
            },
            {
              text: '组织管理',
              link: '/api/system/organization/'
            },
            {
              text: '角色管理',
              link: '/api/system/role/'
            },
            {
              text: '账号管理',
              link: '/api/system/account/'
            },
            {
              text: '菜单管理',
              link: '/api/system/menu/'
            },
            {
              text: '字典管理',
              link: '/api/system/dict/'
            },
            {
              text: '日志管理',
              link: '/api/system/log/'
            },
            {
              text: '意见反馈',
              link: '/api/system/feedback/'
            },
            {
              text: '定时任务',
              link: '/api/system/tasks/'
            }
		]
		}
	  ]
	},
    algolia: {
      appId: 'H38E50PS0X',
      apiKey: '4bd5f47f4e255d70b16ceeec85d12a2c',
      indexName: 'thingskit',
      placeholder: '搜索文档',
      buttonText: '搜索文档',
      translations: {
        button: {
          buttonText: '搜索文档',
          buttonAriaLabel: '搜索文档'
        },
        modal: {
          searchBox: {
            resetButtonTitle: '清除查询条件',
            resetButtonAriaLabel: '清除查询条件',
            cancelButtonText: '取消',
            cancelButtonAriaLabel: '取消'
          },
          startScreen: {
            recentSearchesTitle: '搜索历史',
            noRecentSearchesText: '没有搜索历史',
            saveRecentSearchButtonTitle: '保存至搜索历史',
            removeRecentSearchButtonTitle: '从搜索历史中移除',
            favoriteSearchesTitle: '收藏',
            removeFavoriteSearchButtonTitle: '从收藏中移除'
          },
          errorScreen: {
            titleText: '无法获取结果',
            helpText: '你可能需要检查你的网络连接'
          },
          footer: {
            selectText: '选择',
            navigateText: '切换',
            closeText: '关闭',
            searchByText: '搜索提供者'
          },
          noResultsScreen: {
            noResultsText: '无法找到相关结果',
            suggestedQueryText: '你可以尝试查询',
            reportMissingResultsText: '你认为该查询应该有结果？',
            reportMissingResultsLinkText: '点击反馈'
          }
        }
      }
    }
  },

  markdown: {
    anchor: {
      permalink: renderPermaLink,
    },
    lineNumbers: true,
    config: md => {
      md.use(MarkDownItCustomAnchor),
      md.use(mdItCustomAttrs, 'image', {
        'data-fancybox': "gallery"
      })
    }
  }
})
